package network

import (
	"crypto/hmac"
	"crypto/sha256"
)

// GenMAC generates a MAC for the message
func GenMAC(id int64, msg []byte) []byte {
	mac := hmac.New(sha256.New, []byte("123456789"))
	mac.Write(msg)
	return mac.Sum(nil)
}

// VerifyMAC verifies a MAC for the message
func VerifyMAC(id int64, msg []byte, sig []byte) bool {
	mac := hmac.New(sha256.New, []byte("123456789"))
	mac.Write(msg)
	expectedMac := mac.Sum(nil)
	return hmac.Equal(expectedMac, sig)
}

